123 Bob 100 456 Jill 900 123 Bob 100
==
The ==
(equal-equal) operator is an alias detector.
It checks if two reference variables refer to the same object.
It does not actually look at the objects.
The following program segment illustrates this:
{ CheckingAccount account1 = new CheckingAccount( "123", "Bob", 100 ); CheckingAccount account2 = new CheckingAccount( "456", "Jill", 900 ); CheckingAccount account3; account3 = account1; if ( account1 == account 3 ) System.out.println("An alias has been detected!"); else System.out.println("These are different objects!"); }
It will print out An alias has been detected!.